repl: add syntax highlighting, auto-indentation, and signature hints#64443
repl: add syntax highlighting, auto-indentation, and signature hints#64443hemanth wants to merge 1 commit into
Conversation
|
Review requested:
|
30413de to
14baff1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64443 +/- ##
==========================================
- Coverage 90.23% 90.20% -0.03%
==========================================
Files 741 741
Lines 241375 242165 +790
Branches 45483 45628 +145
==========================================
+ Hits 217800 218454 +654
- Misses 15129 15247 +118
- Partials 8446 8464 +18
🚀 New features to boost your workflow:
|
16ee02c to
b749718
Compare
avivkeller
left a comment
There was a problem hiding this comment.
can these be idiomatic PRs?
|
@avivkeller for sure! having some challenges on my local machine, so depending on the GH CI to report me the build time errors. |
1e7bcec to
088a905
Compare
|
this one has been in my list forever; I thik this should dogfood |
|
Agree. |
088a905 to
eec5763
Compare
|
Also note that #64034 makes some behind-the-scenes improvements as well, and may conflict with these idiomatic PRs code-wise |
ea23882 to
192fcb1
Compare
Signed-off-by: hemanth <hemanth.hm@gmail.com>
192fcb1 to
a7bf2be
Compare
|
Rebased on main, removed the Highlighting, auto-indent, and signature hints are all display-only ( Adapted to the new |
Description
Add REPL enhancements enabled by default:
1. Inline Syntax Highlighting
Uses the Acorn tokenizer (already in
deps/) to colorize JavaScript input in real-time:const,function,if, etc.) → MagentaHighlighting is applied at display time only —
repl.lineremains plain text, so cursor positioning and evaluation are unaffected.2. Auto-Indentation
Automatically inserts 2-space indentation on continuation lines based on brace/bracket/paren depth when entering multiline input.
3. Function Signature Hints
When the user types
functionName(, the function's parameter list is displayed as a dimmed hint below the input line. Uses the V8 Inspector protocol withthrowOnSideEffect: truefor safety.Usage
These features are enabled by default when
useColorsandterminalaretrue. Individual features can be controlled viarepl.start()options (e.g.,syntaxHighlighting: false).Motivation
This addresses the feature requests from #48164, which was closed as not planned. These are quality-of-life improvements that bring the Node.js REPL closer to modern shell experiences (Python's IPython, Ruby's Pry, etc.).
Refs: #48164